package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * ocr状态
 *
 * @author nickbi
 */
@Getter
@AllArgsConstructor
public enum OcrStatusEnum {

  /** 待识别 */
  WAIT(0, "待识别"),
  SUCCESS(1, "识别成功"),
  EMPTY(2, "内容为空"),
  FAIL(3, "失败"),
  IDENTIFYING(4, "识别中"),
  FILE_NOT_FOUND(5, "ocr文件未找到"),
  ;

  private Integer code;
  private String desc;

  public static OcrStatusEnum convert(Integer type) {
    return Arrays.stream(values())
        .filter(x -> x.code.equals(type))
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到拆离状态：" + type));
  }
}
